package com.tuyan.aixiang;

import android.content.Intent;
import android.os.Handler;

import com.google.gson.JsonArray;
import com.tuyan.aixiang.activity.channel.ChannelActivity;
import com.tuyan.aixiang.activity.home.HomeActivity;
import com.tuyan.aixiang.activity.startup.StartupActivity;
import com.tuyan.aixiang.common.AppData;
import com.tuyan.aixiang.common.BaseActivity;
import com.tuyan.aixiang.common.BasePresenter;
import com.tuyan.aixiang.common.Constant;
import com.tuyan.aixiang.common.StorageKey;
import com.tuyan.aixiang.util.StorageUtil;

public class MainActivity extends BaseActivity<BasePresenter> {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    public void bindView() {
        super.bindView();
        immersion();
//        new Handler().postDelayed(this::enter, 2000);
        new Handler().postDelayed(this::enter, 1);
    }

    private void enter() {
        if (StorageUtil.getBoolean(StorageKey.FIRST_START, true)) {
            JsonArray arr = new JsonArray();
            arr.add(Constant.SHORT_CUT_ALARM);
            arr.add(Constant.SHORT_CUT_SHARE);
            StorageUtil.setObject(StorageKey.SHORT_CUT, arr);
            startActivity(new Intent(this, StartupActivity.class));
        } else {
            if (null == AppData.getToken()) {
                startActivity(new Intent(this, ChannelActivity.class));
//                HomeActivity.start(this);
//                startActivity(new Intent(this, QrScanActivity.class));
            } else {
                HomeActivity.start(this);
            }

        }
        finish();

    }
}